﻿Test Assert_Should_Throw_Exception_When_Condition_Is_False {
	
	[string]$message = "This should throw an exception"
	try
	{
		Assert $false $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		if ($e.Message -NE $message)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test Assert_Should_Throw_Exception_When_Condition_Is_False_And_Return_Default_Message_If_One_Is_Not_Provided {

	[string]$message = "Test Failed"
	try
	{
		Assert $false
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		if ($e.Message -NE $message)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test AssertFail_Should_Always_Throw_Exception {

	[string]$message = "AssertFail always throws an exception"
	try
	{
		AssertFail $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		if ($e.Message -NE $message)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test AssertAreEqual_Should_Throw_Exception_When_Arguments_Not_Equal {
	
	[string]$message = "Test User Message"
	[string]$arg1 = "hello"
	[string]$arg2 = "goodbye"
	
	try
	{
		AssertAreEqual $arg1 $arg2 $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		$expectedMessage = "Expected: goodbye But was: hello`nMessage: Test User Message"
		if ($e.Message -NE $expectedMessage)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test AssertAreEqual_Should_Not_Throw_Exception_When_Arguments_Are_Equal {
	
	[string]$arg1 = "hello"
	[string]$arg2 = "hello"
	
	AssertAreEqual $arg1 $arg2
}

Test AssertGreatherThan_Should_Throw_Exception_When_Actual_Is_LessThan_Target {
	
	[string]$message = "Test User Message"
	[int]$actual = 1
	[int]$target = 2
	
	try
	{
		AssertGreaterThan $actual $target $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		$expectedMessage = "$actual was not greater than $target`nMessage: Test User Message"
		if ($e.Message -NE $expectedMessage)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test AssertGreaterThan_Should_Throw_Exception_When_Actual_Equals_Target {
    [string]$message = "Test User Message"
	[int]$actual = 1
	[int]$target = 1
	
	try
	{
		AssertGreaterThan $actual $target $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		$expectedMessage = "$actual was not greater than $target`nMessage: Test User Message"
		if ($e.Message -NE $expectedMessage)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}

}

Test AssertGreatherThan_Should_Not_Throw_Exception_When_Actual_Is_GreaterThan_Target {
	
	[int]$actual = 2
	[int]$target = 1
	
    AssertGreaterThan $actual $target
}

Test AssertLessThan_Should_Throw_Exception_When_Actual_GreaterThan_Target {

	[string]$message = "Test User Message"
	[int]$actual = 2
	[int]$target = 1
	
	try
	{
		AssertLessThan $actual $target $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		$expectedMessage = "$actual was not less than $target`nMessage: Test User Message"
		if ($e.Message -NE $expectedMessage)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test AssertLessThan_Should_Throw_Exception_When_Actual_Equals_Target {

	[string]$message = "Test User Message"
	[int]$actual = 1
	[int]$target = 1
	
	try
	{
		AssertLessThan $actual $target $message
		throw "Exception was not thrown!"
	}
	catch
	{
		$e = $_.Exception
		$expectedMessage = "$actual was not less than $target`nMessage: Test User Message"
		if ($e.Message -NE $expectedMessage)
		{
			$msg = "Expected Exception Message Was Not Thrown.`nExpected: {0} but was {1}" -f $message, $e.Message 
			throw $msg
		}
	}
}

Test AssertLessThan_Should_Not_Throw_Exception_When_Actual_Is_LessThan_Target {

    [int]$actual = 1
	[int]$target = 2
	
    AssertLessThan $actual $target
}